using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class GridSelection : UIBehaviour
{
    private RectTransform m_rectTransform;
    public RectTransform rectTransform
    {
        get
        {
            if (m_rectTransform == null) m_rectTransform = GetComponent<RectTransform>();
            return m_rectTransform;
        }
    }

    [SerializeField]
    private TMP_Text m_textChild;
    public string text
    {
        get => m_textChild.text;
        set
        {
            m_textChild.text = value;
        }
    }

    public Color textColor
    {
        get => m_textChild.color;
        set => m_textChild.color = value;
    }
    

    public float transparency
    {
        get
        {
            return image.color.a;
        }
        set
        {
            var bgColor = image.color;
            bgColor.a = value;
            image.color = bgColor;

            var tColor = m_textChild.color;
            tColor.a = value;
            m_textChild.color = tColor;
        }
    }

    [SerializeField]
    private Image image;
/*
    [Range(0f, 1f)]
    public float m_transparency;

#if UNITY_EDITOR
    protected override void OnValidate()
    {
        transparency = m_transparency;
    }
#endif
*/
}
